//
//  UIViewController+AlertExtension.m
//  RPay
//
//  Created by CharlieLiao on 2017/7/3.
//  Copyright © 2017年 Charlie. All rights reserved.
//

#import "UIViewController+AlertExtension.h"
#import "MBProgressHUD.h"

@implementation UIViewController (AlertExtension)

- (void)showLoading
{
    MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode = MBProgressHUDModeIndeterminate;
    hud.removeFromSuperViewOnHide = true;
}

- (void)hideLoading
{
    [MBProgressHUD hideHUDForView:self.view animated:YES];
}

- (void)alert:(NSString*)msg
{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.userInteractionEnabled = false;
    hud.removeFromSuperViewOnHide = true;
    hud.mode = MBProgressHUDModeText;
    hud.detailsLabel.text = msg;
    [hud hideAnimated:YES afterDelay:2];
}

@end
